<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8"%>
<!doctype html>

<html class="no-js">

<head>
<%@ include file="./commoms/link.txt"%>
<meta name="description" content="devicemanager">
<script src="assets/js/pagejs/sos.js"></script>
</head>

<body>
	<%@ include file="./commoms/userHeader.txt"%>

	<div class="admin-content">
		<div class="admin-content-body">
			<div class="am-cf am-padding am-padding-bottom-0">
				<div class="am-fl am-cf">
					<strong class="am-text-primary am-text-lg">表格</strong> / <small>Table</small>
				</div>
			</div>

			<hr>

			<div class="am-g">
				<div class="am-u-sm-12 am-u-md-6">
					<div class="am-btn-toolbar">
						<div class="am-btn-group am-btn-group-xs">
							
					<!--  	<button type="button" id="batchdelete"
								class="am-btn am-btn-default">
								<span class="am-icon-trash-o"></span> 删除
							</button>-->	
						</div>
					</div>
				</div>
				
			
			</div>
			<div class="am-g">
				<div class="am-u-sm-12">
					<form class="am-form">
						<table class="am-table am-table-striped am-table-hover table-main">
							<thead>
								<tr>
								
									<th class="table-id">ID</th>
									<th class="table-title">设备名</th>
									<th class="table-author am-hide-sm-only">设备码</th>
									<th class="table-author am-hide-sm-only">持有人</th>
									
									<th class="table-title am-hide-sm-only">经度</th>
										<th class="table-title am-hide-sm-only">纬度</th>
											<th class="table-date am-hide-sm-only">状态</th>
											<th class="table-date am-hide-sm-only">sos时间</th>
									<th class="table-set">操作</th>
								</tr>
							</thead>

							<tbody id="pagecontainer">

							</tbody>
						</table>
				
						<hr />
					</form>
				</div>

			</div>
		</div>

	</div>
	</div>
	<a href="#"
		class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
		data-am-offcanvas="{target: '#admin-offcanvas'}"></a>


	<script type="text/javascript">
		var currentpage = 1;
		var pages = 1;
		var $pagecontainer = $('#pagecontainer');
		var ldata = null;
		var nums = 0;
		getall();
		
		
		//int opr= setInterval(getall, 10000);
		
		
		
		
		function getall(){
			getdiffstatuscontent1(domain + "/api/sos/getsosofrole.do", {
			}, $pagecontainer);
			
			
			
			
			
		}
		
		function getdiffstatuscontent1(url, parameters, $pagecontainer) {
						myAjax(url, parameters, function(data) {
	                   
							nums=data.nums;
							ldata =data.result;
							drawsosContent($pagecontainer, ldata);

						});

					}
		
	
		

		function further(className, id) {
			var index = id.replace(className, "");

		/*	if (className == 'del') {
				opFunction(domain + '/api/device/delete.do', {
					'deviceid' : ldata[index].deviceid
				}, 'devicemanager.jsp')
			}*/

			if (className == 'look') {

				
				openPostWindow(domain + '/sosdetail.jsp', {
					'sosiid' : ldata[index].sosiid
				});
				window.event.returnValue = false;
			}
		}

		function opFunction(url, data, location) {
			myAjax(url, data, function(msg) {
				window.location.href = location;
				window.event.returnValue = false;
			});

		}
		
		function drawsosContent($pagecontainer, data) {
			var temp = '';
			$.each(
							data,
							function(i, item) {
								var index = item.id;
								var status;
								if(item.status==1)
									status='危险';
								if(item.status==2)
									status='已查看';
								if(item.status==3)
									status='已经安全';
								temp = '<td><div class="am-btn-toolbar"><div class="am-btn-group am-btn-group-xs">'
										+ ' <button id=look'
										+ i
										+ ' class=" look am-btn am-btn-default am-btn-xs am-hide-sm-only"><span class="am-icon-pencil-square-o"></span> 查看</button>'
									

										+ ' </div> </div></td>'

								$pagecontainer.append(' <tr class="sos" id=sos'
										+ i + '><td>'
										+ (i + 1) + '</td><td>' + item.device.devicename
										+ '</td><td>' + item.device.devicecode
										+ '</td><td>' + item.device.holder
										+ '</td><td>' + item.longtitude
										+ '</td><td>' + item.latitude
										+ '</td><td>' + status
										+ '</td> <td>'
										+ item.createtime + '</td>' + temp + '</tr>');

							});

		}


		$pagecontainer.on('click','.sos',function(event){
			var pid=event.currentTarget.id;
			 var index=pid.replace('sos',"");
			if(event.target.nodeName!='BUTTON'&&event.target.nodeName!='INPUT')
				{
				openPostWindow(domain + '/sosdetail.jsp', {
					'sosiid' : ldata[index].sosiid
				});
				
				}
		});
		
		
		/*$pagecontainer.on('click', '.del', function(event) {
		further('del', event.currentTarget.id)
		
		});*/
	


		$pagecontainer.on('click', '.look', function(event) {
		
		further('look', event.currentTarget.id)
		});

	
	
		
	</script>

</body>
</html>











